import request from '@/utils/request'

// 查询采购订单列表
export function listProcuredOrders(query) {
  return request({
    url: '/product/ProcuredOrders/list',
    method: 'get',
    params: query
  })
}

export function listReceiptProcuredOrders(query) {
  return request({
    url: '/product/ProcuredOrders/receipt/list',
    method: 'get',
    params: query
  })
}

// 查询采购订单详细
export function getProcuredOrders(ordersId) {
  return request({
    url: '/product/ProcuredOrders/' + ordersId,
    method: 'get'
  })
}

// 新增采购订单
export function addProcuredOrders(data) {
  return request({
    url: '/product/ProcuredOrders',
    method: 'post',
    data: data
  })
}

// 修改采购订单
export function updateProcuredOrders(data) {
  return request({
    url: '/product/ProcuredOrders',
    method: 'put',
    data: data
  })
}

// 删除采购订单
export function delProcuredOrders(ordersId) {
  return request({
    url: '/product/ProcuredOrders/' + ordersId,
    method: 'delete'
  })
}

//申请预付款
export function addRequestAdvance(data) {
  return request({
    url: '/product/ProcuredOrders/insertRequestAdvance',
    method: 'post',
    data: data
  })
}
//申请应付款
export function addRequestAdvanceQuash(data) {
  return request({
    url: '/product/ProcuredOrders/insertRequestAdvanceQuash',
    method: 'post',
    data: data
  })
}
//申请记录
export function selectRequestAdvanceList(query) {
  return request({
    url: '/product/ProcuredOrders/selectRequestAdvanceList',
    method: 'get',
    params: query
  })
}

//取消申请
export function getRequestAdvanceByRequestId(requestIds) {
  return request({
    url: '/product/ProcuredOrders/requestAdvanceByRequestId/' + requestIds,
    method: 'put',
  })
}

//查询最大可申请多少钱
export function getSelectTotalAmountDue(ordersId) {
  return request({
    url: '/product/ProcuredOrders/selectTotalAmountDue/' + ordersId,
    method: 'get',
  })
}

//查询总入库数
export function getUpdateInboundNumber(ordersId) {
  return request({
    url: '/product/ProcuredOrders/updateInboundNumber/' + ordersId,
    method: 'put',
  })
}

// 新增快递单号
export function updateExpressNumber(data) {
  return request({
    url: '/product/ProcuredOrders/updateExpressNumber',
    method: 'put',
    data: data
  })
}

//查询最大可申请多少钱
export function getProcuredOrderAmountDueById(ordersId) {
  return request({
    url: '/product/ProcuredOrders/selectProcuredOrderAmountDueById/' + ordersId,
    method: 'get',
  })
}
//申请付款
export function addPaymentRequestQuash(data,componentPath,procuredOrderId) {
  return request({
    url: '/product/ProcuredOrders/insertPaymentRequestQuash',
    method: 'post',
    params: {
      componentPath,
      procuredOrderId
    },
    data: data
  })
}
//申请记录
export function selectPaymentRequestList(query) {
  return request({
    url: '/product/ProcuredOrders/selectPaymentRequestList',
    method: 'get',
    params: query
  })
}
//取消申请
export function setCancelPaymentRequestByIds(paymentRequestIds) {
  return request({
    url: '/product/ProcuredOrders/setCancelPaymentRequestByIds/' + paymentRequestIds,
    method: 'put',
  })
}
//批量申请付款
export function addBatchPaymentRequestQuash(ordersIds,componentPath) {
  return request({
    url: '/product/ProcuredOrders/insertBatchPaymentRequestQuash/' + ordersIds,
    method: 'post',
    params: { componentPath }
  })
}

// 查询审核记录
export function selectPaymentRequestByStatus(query) {
  return request({
    url: '/product/ProcuredOrders/selectPaymentRequestByStatus',
    method: 'get',
    params: query
  })
}
// 查询审核流程记录
export function getPaymentRequestProcessList(paymentRequestId) {
  return request({
    url: '/product/ProcuredOrders/selectPaymentRequestProcessList/' + paymentRequestId,
    method: 'get',
  })
}
// 更新审核流程
export function updateProcessStatus(data) {
  return request({
    url: '/product/ProcuredOrders/updateProcessStatus',
    method: 'post',
    data: data
  })
}
//申请退款
export function addPaymentReturnQuash(data,componentPath,procuredOrderId) {
  return request({
    url: '/product/ProcuredOrders/insertPaymentReturnQuash',
    method: 'post',
    params: {
      componentPath,
      procuredOrderId
    },
    data: data
  })
}
//审核记录
export function selectPaymentRequestLogList(query) {
  return request({
    url: '/product/ProcuredOrders/selectPaymentRequestLogList',
    method: 'get',
    params: query
  })
}
//驳回标记处理
export function setSolvePaymentRequestByIds(paymentRequestId) {
  return request({
    url: '/product/ProcuredOrders/setSolvePaymentRequestByIds',
    method: 'post',
    params: {
      paymentRequestId
    }
  })
}







// 获取未收货的来源单据号列表
export function listUnreceivedOrders(params) {
  return request({
    url: '/product/ProcuredOrders/orders/unreceivedOrders',
    method: 'get',
    params: params
  });
}

// 获取订单详情
export function getOrdersDetails(data) {
  return request({
    url: '/depot/orders/ordersDetails',
    method: 'post',
    data: data
  });
}
// 查询该申请的采购订单数据（商品信息，入库，出库信息）
export function getOrdersProductList(ordersId) {
  return request({
    url: '/product/ProcuredOrders/getOrdersProductList/' + ordersId,
    method: 'get'
  })
}
//撤回订单
export function revokeProcuredOrders(procuredOrderId,revokeRemark) {
  return request({
    url: '/product/ProcuredOrders/revokeProcuredOrders',
    method: 'post',
    params: {
      procuredOrderId,
      revokeRemark
    }
  })
}